<div class="row">
	<div class="col-md-12">
		<form id="editForm" class="form-horizontal" action="${request.contextPath}/system/config/dictionary/update" method="post" onsubmit="return false">
			<input type="hidden" id="id" name="id" value="${sysDictionary.id}">
			<div class="box-body">
				<div class="form-group">
					<label id="sysDictionaryNameLabel" for="sysDictionaryName" class="col-sm-1 control-label">名称</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="name"  id="sysDictionaryName"  value="${sysDictionary.name}" placeholder="输入名称...">
					</div>
					<label id="sysDictionaryCodeLabel" for="sysDictionaryCode" class="col-sm-1 control-label" >编码</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="code" id="sysDictionaryCode" value="${sysDictionary.code}" placeholder="输入编码...">
					</div>
				</div>
				<div class="form-group">
					<label id="sysDictionarySeqLabel" for="sysDictionarySeq" class="col-sm-1  control-label">排序</label>
					<div class="col-sm-5">
						<input class="form-control" name="seq" id="sysDictionarySeq" type="number" value="${sysDictionary.seq}" placeholder="输入排序号...">
					</div>
					<label id="sysDictionaryStatusLabel" for="sysDictionaryStatus" class="col-sm-1  control-label">状态</label>
					<div class="col-sm-5">
						<select class="form-control" id="sysDictionaryStatus"  name="status" value="${sysDictionary.status}" style="width: 100%;" placeholder="选择状态...">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label id="sysDictionaryTypeLabel" for="sysDictionaryType" class="col-sm-1  control-label">类型</label>
					<div class="col-sm-11">
						<select class="form-control" id="sysDictionaryType" name="type"  value="${sysDictionary.type}" style="width: 100%;"  placeholder="选择字典类型...">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label id="sysDictionaryDescriptionLabel" class="col-sm-1 control-label" >描述</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="description" id="sysDictionaryDescription"  value="${sysDictionary.description}" placeholder="输入描述...">
					</div>
				</div>
				<div class="form-group">
					<label id="sysDictionaryRemarkLabel" class="col-sm-1 control-label">备注</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="remark" id="sysDictionaryRemark"  value="${sysDictionary.remark}" placeholder="输入备注...">
					</div>
				</div>
				<div class="error-message text-center" >
					<span class="error-icon"></span>
					<span id="error-msg" class="error-msg" ></span>
				</div>
             </div>
			<div class="box-footer">
				<div class="pull-right">
               		<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 更新</button>
               		<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i> 关闭</button>
				</div>
          	</div>
		</form>
	</div>
</div>
<script type="text/javascript">
function ajaxSubmit(form) {
	
	var $form = $(form);
	
	if ($form.length === 1 && $form.validate()) {
		$.post(form.action, $form.serialize(),function(result) {
			if (result.success) {
				$("#lgModal").modal('hide');
	        	alertMsg(result.message,"success");
                dataGridRefresh();
			} else {
				$form.find(".error-msg").show();
				$form.find(".error-msg").html(result.message);
			}
		}, 'json');
	}
}

$(function() {
    $("#sysDictionaryType").select2({
        data: DictionaryTypeStore
    });
    $("#sysDictionaryStatus").select2({
        data: StatusStore
    });

	$editForm = $("#editForm");
    $editForm.validate({
		rules: {
            name: {
                required: true
            },
            code: {
                required: true
            },
            type: {
                required: true
            },
            status: {
                required: true
            },
            seq: {
                required: true
            }
		},
		messages: {
            name:{
                required:"名称不能为空！"
            },
            code:{
                required:"编码不能为空！"
            },
            type: {
                required: "类型不能为空！"
            },
            status: {
                required: "状态不能为空！"
            },
            seq: {
                required: "排序号不能为空！"
            }
		},
		submitHandler:ajaxSubmit,
		errorLabelContainer:".error-msg",
		wrapper:"li",
		showErrors:function(errorMap,errorList) {
			if(errorList.length>0){
                $editForm.find(".error-msg").html(errorList[0].message);
			}else{
                $editForm.find(".error-msg").html("");
			}
		},
		onkeyup: false
	});
});
</script>